const app = getApp()
const userInfo = wx.getStorageSync('userInfo')
const defaultAvatarUrl = userInfo.avatarUrl
 
 
Page({
/**
   * 页面的初始数据
   */
  data: {
    avatarUrl: defaultAvatarUrl,
    theme: wx.getSystemInfoSync().theme,
  },
 
  onChooseAvatar(e) {
    const { avatarUrl } = e.detail 
    this.setData({
      avatarUrl,
    })
    const userInfo = wx.getStorageSync('userInfo')
    wx.setStorageSync('userInfo', {
      avatarUrl,
      nickname:userInfo.nickname
    }) 
   
  },
  formSubmit(e){
    const userInfo = wx.getStorageSync('userInfo')
    wx.setStorageSync('userInfo', {
      nickName: e.detail.value.nickname,
      avatarUrl:userInfo.avatarUrl
    }) 
      wx.switchTab({
        url: '/pages/me/me',
      })
  },
 
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.onThemeChange((result) => {
      this.setData({
        theme: result.theme
      })
    })
  }
})